package com.project.light.service.impl;

import com.project.light.dto.DataGroupInfo;
import com.project.light.dto.DataGroupInfoParam;
import com.project.light.dto.DateParam;
import com.project.light.entity.Group;
import com.project.light.mapper.GroupMapper;
import com.project.light.service.GroupService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GroupServiceImpl implements GroupService {

    @Resource
    private GroupMapper groupMapper;

    @Override
    public Group getByGroupId(Integer groupId) {
        Example example = new Example(Group.class);
        Example.Criteria c = example.createCriteria();
        c.andEqualTo("groupID", groupId);
        List<Group> list = groupMapper.selectByExample(example);
        return list.size() == 0 ? null : list.get(0);
    }

    @Override
    public List<DataGroupInfoParam> getSysList(DateParam dateParam) {
        List<DataGroupInfoParam> list = groupMapper.getSysList(dateParam);
        return list;
    }

    @Override
    public List<DataGroupInfo> getGroupList(DateParam dateParam) {
        List<DataGroupInfo> list = groupMapper.getGroupList(dateParam);
        return list;
    }
}
